<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const arr = [1, 2, 3, 4];
        const res = [1, 4, 9, 16];
        function transformArr(arr) {
            const res = [];
            for (const item of arr) {
                res.push(item ** 2);
            }
            return res;
        }
        console.log(res);


        const arr1 = ['jhjfkk', 'fgnkcjf', 'hjfjh', 'fj', 'gfjfhj'];
        const res1 = arr1.map (function (item) {
            return item.length;
        })
        console.log(res1);

        const input1 = [
            {
                name: 'zhangsan',
                age: 18,
            },
            {
                name: 'lisi',
                age: 28,
            },
            {
                name: 'wangmazi',
                age: 15,
            }
        ]

        const res2 = input1.map(function (item) {
            return item.name;
        })
        console.log(res2);


        const res3 = input1.map(function (item) {
            return [item.name,item.age];
        })
        console.log(res3);

        const input2 = [
            [1, 3],
            [5, 12],
            [1, 3],
            [5, 12],
            [1, 3],
            [5, 12],
        ]

        const res4 = input2.map(function (item) {
            // for (const iterator of item) {
            //     return Math.min(iterator);
            // }
            return Math.min(...item);
        })
        console.log(res4);

        const input3 = [1.2, 2, 3.3, Math.PI, 5.7];
        const res5 = input3.map(function (item) {
            return Math.floor(item);
        })
        console.log(res5);

        const input4 = [
            {
                name: 'zhangsan',
                age: 18,
            },
            {
                name: 'lisi',
                age: 28,
            },
            {
                name: 'wangmazi',
                age: 15,
            }
        ]
        const res6 = input4.map(function (item) {
            return {a:item.name,b:item.age};
        })
        console.log(res6);
    </script>
</body>
</html>